#include<stdio.h>
#include<stdlib.h>
#define max 10000
int a[max], b[max], c[max];
int t;
typedef struct node* Tree;
struct node {
    int data;
    Tree Left;
    Tree Right;
};
Tree Insert(Tree T, int x)
{
    if (T == NULL) {
        T = (Tree)malloc(sizeof(struct node));
        T->data = x;
        T->Left = T->Right = NULL;
    }
    else {
        if (x < T->data) {
            T->Left = Insert(T->Left, x);
        }
        else {
            T->Right = Insert(T->Right, x);
        }
    }
    return T;
}
Tree swap(Tree T)
{
    if (T) {
        T->Left = swap(T->Left);
        T->Right = swap(T->Right);
        Tree tmp;
        tmp = T->Left;
        T->Left = T->Right;
        T->Right = tmp;
    }
    return T;
}
void pre(Tree T)
{
    if (T) {
        b[t++] = T->data;
        pre(T->Left);
        pre(T->Right);
    }
}
void post(Tree T)
{
    if (T) {
        post(T->Left);
        post(T->Right);
        c[t++] = T->data;
    }
}
int main()
{
    int n, flag = 0, i;
    Tree T = NULL, T1;
    scanf("%d", &n);
    for (int k = 0; k < n; k++) {
        scanf("%d", &a[k]);
        T = Insert(T, a[k]);
    }
    if (n == 1) {
        printf("YES\n%d", a[0]);
        return 0;
    }
    t = 0;
    pre(T);
    for (i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            flag++;
            break;
        }
    }
    if (flag == 0) {
        t = 0;
        post(T);
        printf("YES\n");
        for (i = 0; i < n; i++) {
            if (i == 0)printf("%d", c[i]);
            else printf(" %d", c[i]);
        }
    }
    else {
        t = 0;
        T1 = swap(T);
        pre(T1);
        for (i = 0; i < n; i++) {
            if (a[i] != b[i]) {
                flag++;
                break;
            }
        }
        if (flag == 1) {
            t = 0;
            post(T);
            printf("YES\n");
            for (i = 0; i < n; i++) {
                if (i == 0)printf("%d", c[i]);
                else printf(" %d", c[i]);
            }
        }
        else
            printf("NO");
    }
    return 0;
}